package com.ld.cooperative.utils;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * Mp的自动装配
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {

        this.setFieldValByName("createTime", new Date(), metaObject);
        this.setFieldValByName("updateTime", new Date(), metaObject);
        this.setFieldValByName("avatar", "default_avatar.jpg", metaObject);
        this.setFieldValByName("role", "用户", metaObject);
        this.setFieldValByName("clubAudit", "2", metaObject);
        this.setFieldValByName("activityStatus", "2", metaObject);
        this.setFieldValByName("isSend", "0", metaObject);
        this.setFieldValByName("registrationStatus", "2", metaObject);
        this.setFieldValByName("score", 0.0, metaObject);
        this.setFieldValByName("noticeStatus", "0", metaObject);
        this.setFieldValByName("noticeAudit", "2", metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime", new Date(), metaObject);
    }
}
